import java.util.Scanner;

/**
 * 计算日期到天数转换
 */
public class CalculateDays {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNext()) {
            int year = scanner.nextInt();
            int month = scanner.nextInt();
            int day = scanner.nextInt();
            int[] array = new int[]{31,28,31,30,31,30,31,31,30,31,30,31};
            // 计算是否为闰年
            if (year % 4 == 0 || year % 400 == 0) {
                array[1] = 29;
            }
            int sum = 0;
            for (int i=0; i<month-1; i++) {
                sum += array[i];
            }
            sum += day;
            System.out.println(sum);
        }
    }
}
